/*
 * Title: WADS
 * Description: Web-based Auto flow Documents System
 * Copyright: 2007
 * Company: CoE
 * @author: Mr.Nattasan Wang-Aphisit
 * @version 1.1
 */

package wads.servlet;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import wads.com.WADTools;

public class DeleteSuccessDocumentServlet extends HttpServlet {
  private static final long serialVersionUID = 7918739218901830239L;
  
  private static final String CONTENT_TYPE = WADTools.SERVLET_CONTENT_TYPE;
  /**Initialize global variables*/
  String restrictedUser;
  String templateID;
  String app_Path;
  String serverName;
  Properties prop = new Properties();
  File docFile;

  public void init(ServletConfig config) throws ServletException {
    super.init(config);
  }
  /**Process the HTTP Get request*/
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType(CONTENT_TYPE);

    templateID = request.getParameter("ID");

    //System.out.println(templateID + "::" + restrictedUser);
    //app_Path = this.getInitParameter("app_Path");
    app_Path = WADTools.APP_PATH;

    docFile = new File(app_Path+"res/docs/SuccessDocument/trans_" + templateID + ".info");
   // docFile = new File(app_Path + "InProgressAutoDoc/" + restrictedUser + "/trans_000046.info");

    if(docFile.isFile()){
      docFile.delete();
    }

    prop.load(new FileInputStream(app_Path+"res/wad_app.properties"));
    serverName = prop.getProperty("ServerName");

    response.sendRedirect("servlet/ManageSuccess");
  }
  /**Clean up resources*/
  public void destroy() {
  }
}
